/**
 * @author Shine Chen
 * @date 2011.10.28
 */

package org.mini.core
{
	import com.shine.utils.DisplayObjectUtil;
	
	import flash.display.Sprite;
	import flash.utils.Dictionary;
	
	import org.mini.main.Application;

	public class LevelView
	{
		static private var _total:uint;
		static private var _layers:Dictionary;
		
		public static function init(total:uint):void
		{
			for(var i:uint=0;i<total;i++){
				var layer:Sprite=new Sprite();
				(_layers ||=new Dictionary(true))[(i+1)]=layer;
				Application.instance.addChild(layer);
			}
		}
		
		public static function getLayer(index:uint):Sprite
		{
			if(_layers==null || _layers[index]==undefined) return null;
			return _layers[index];
		}
		
		public static function dispose():void
		{
			if(_layers){
				for(var key:* in _layers){
					var child:Sprite=_layers[key];
					if(child) DisplayObjectUtil.removeAllChildren(child);
					delete _layers[key];
				}
			}
		}
	}
}